package fr.vvins.core.search.tools;

import java.util.List;
import java.util.Map;

import fr.vvins.core.search.SearchEngineException;
import fr.vvins.core.search.query.SearchFacetResult;
import fr.vvins.core.search.query.SearchResult;

/**
 * A common interface for search a result from front office.
 * This tools give some simple method to build a search query.
 * @author fguay
 */
/**
 * @author fguay
 *
 */
public interface SearchTools {
	
	/**
     * Build a global search query on all type.
     * @param field
     * @param start
     * @return
     * @throws SearchEngineException
     */
    public SearchResult searchAll(String field, int start, int max) throws SearchEngineException;
    
    /**
     * Build a query on a specific entity (vin not on Vigneron for exemple)
     * @param entity
     * @param field
     * @param start
     * @return
     * @throws SearchEngineException
     */
    public SearchResult searchEntity(String entity, String field, int start, int max) throws SearchEngineException;
    
 
     /**
     * Execute a suggest form field characters.
     * @param field
     * @return
     * @throws SearchEngineException
     */
    public List<String> suggest(String field, int max) throws SearchEngineException;
 
    /**
     * Execute a suggest form field characters for a specific entity
     * @param field
     * @return
     * @throws SearchEngineException
     */
    public List<String> suggestEntity(String entity, String field, int max) throws SearchEngineException;
 
    
    /**
     * Build a global search query on all type with a facet filter.
     * @param field
     * @param start
     * @return
     * @throws SearchEngineException
     */
    public SearchFacetResult searchAllByFacet(String field, List<String> facets, Map<String, String> facetsLimit, Map<String,Map<String,Long>> facetsRange,  int start, int max) throws SearchEngineException;
    
    /**
     * Build a query on a specfic entity with facet filter.
     * @param field
     * @param start
     * @return
     * @throws SearchEngineException
     */
    public SearchFacetResult searchEntityByFacet(String entity, String field, List<String> facets, Map<String, String> facetsLimit, Map<String,Map<String,Long>> facetsRange, int start, int max) throws SearchEngineException;
    
    /**
     * Build a simple query.
     * @param query
     * @return
     * @throws SearchEngineException
     **/
    public SearchResult search(String query) throws SearchEngineException;
 
}
